package com.dragon.modules.yuegou.service.impl.member;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dragon.modules.yuegou.entity.member.TemplateRightsEntity;
import com.dragon.modules.yuegou.mapper.member.TemplateRightsMapper;
import com.dragon.modules.yuegou.model.member.TemplateRights;
import com.dragon.modules.yuegou.query.member.TemplateRightsQuery;
import com.dragon.modules.yuegou.service.member.TemplateRightsService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 会员卡等级权益关联表 服务实现
 *
 * @author pbuilder generated
 * @date 2021-12-15 11:38:52
 * @version 2.0
 */
@Service("memTemplateRightsService")
public class TemplateRightsServiceImpl
		extends ServiceImpl<TemplateRightsMapper, TemplateRightsEntity>
		implements TemplateRightsService {

	@Override
	public void saveTemplateRights(String templateSetId, String templateGradeId, List<TemplateRights> saveRights) {
		TemplateRightsQuery query = new TemplateRightsQuery();
		query.setTemplateSetId(templateSetId);
		query.setTemplateGradeId(templateGradeId);
		remove(query.toQueryWrapper());

		if(CollectionUtils.isNotEmpty(saveRights)) {
			for(TemplateRights right : saveRights) {
				save(right);
			}
		}
	}
}